package com.tankgame.its381b;

import java.io.IOException;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.TiledLayer;

/**
 *
 * @author Tank Team
 */
public class BackgroundTiledLayer extends TiledLayer {

    private Image backgroundImg;

    // creates the background using TiledLayer
    BackgroundTiledLayer() throws IOException {
       super(10, 10, Image.createImage("/res/background.png"), 16, 16);

        // array that specifies what image goes where
        int[] cells = {
            3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
            3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
            3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
            3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
            3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
            3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
            3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
            3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
            2, 1, 1, 1, 1, 2, 1, 1, 2, 1,
            1, 1, 2, 1, 1, 1, 2, 1, 1, 2
        };

        // set the background with the images
        for (int i = 0; i < cells.length; i++) {
            int column = i % 10;
            int row = (i - column) / 10;
            setCell(column, row, cells[i]);
        }
    }
}
